package cn.dengta.webapp.model;

import cn.dengta.webapp.im.enums.ChatType;

/**
 * 聊天业务模式
 */
public interface ChatBizMode {

	ChatType type();

	/** 是否是定制业务通话（速配、破冰等） */
	default boolean customCall() {
		return false;
	}

	ChatBizMode audioCustomCall = new SpeedDatingChatBizMode(ChatType.AUDIO);
	ChatBizMode videoCustomCall = new SpeedDatingChatBizMode(ChatType.VIDEO);

	static ChatBizMode of(ChatType type, boolean customCall) {
		if (customCall) {
			return type == ChatType.AUDIO ? audioCustomCall : videoCustomCall;
		}
		return type;
	}

	class SpeedDatingChatBizMode implements ChatBizMode {

		final ChatType type;

		public SpeedDatingChatBizMode(ChatType type) {
			this.type = type;
		}

		@Override
		public final ChatType type() {
			return type;
		}

		@Override
		public final boolean customCall() {
			return true;
		}

	}

}
